package com.ygqh.baby.mapper;

import com.ygqh.baby.ao.ProductStatus;
import com.ygqh.baby.ao.PromotionType;
import com.ygqh.baby.ao.QueryInfo;
import com.ygqh.baby.ao.SalesPlatform;
import com.ygqh.baby.kids.entity.bo.KidsProductExt;
import com.ygqh.baby.model.*;
import com.ygqh.baby.po.YgProduct;
import com.ygqh.baby.po.YgProductExample;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author admin
 */
public interface YgProductMapper {

    int countByExample(YgProductExample example);

    int deleteByExample(YgProductExample example);

    int deleteByPrimaryKey(Long id);

    int insert(YgProduct record);

    int insertSelective(YgProduct record);

    List<YgProduct> selectByExample(YgProductExample example);

    YgProduct selectByPrimaryKey(Long id);

    int updateByExampleSelective(@Param("record") YgProduct record, @Param("example") YgProductExample example);

    int updateByExample(@Param("record") YgProduct record, @Param("example") YgProductExample example);

    int updateByPrimaryKeySelective(YgProduct record);

    int updateByPrimaryKey(YgProduct record);

    int countSuper(@Param("productName") String productName, @Param("groupId") Long groupId,
                   @Param("productStatus") String productStatus, @Param("supplierId") Long supplierId,
                   @Param("isSpecial") Boolean isSpecial, @Param("productCode") String productCode,
                   @Param("isGroup") Boolean isGroup, @Param("promotionType") PromotionType promotionType,
                   @Param("vipPrice") BigDecimal vipPrice, @Param("preSaleDate") Boolean preSaleDate);

    List<YgProduct> selectSuper(@Param("queryInfo") QueryInfo queryInfo, @Param("productName") String productName,
                                @Param("groupId") Long groupId, @Param("productStatus") String productStatus,
                                @Param("supplierId") Long supplierId, @Param("isSpecial") Boolean isSpecial,
                                @Param("productCode") String productCode, @Param("isGroup") Boolean isGroup,
                                @Param("promotionType") PromotionType promotionType,
                                @Param("vipPrice") BigDecimal vipPrice, @Param("preSaleDate") Boolean preSaleDate);

    YgProductModel findDetailModel(@Param("id") Long id);

    YgProductModel findDetailModelV2(@Param("id") Long id);

    List<YgProductModel> findDetailModelByGroup(@Param("groupId") Long groupId);

    List<YgProduct> findDetailById(@Param("list") List<Long> idList);

    List<YgProduct> findDetailByGroupId(@Param("groupId") Long groupId);

    List<Map<String, Object>> selectInStockBySkuIds(@Param("skuIds") Long[] skuIds);

    List<Map<String, Object>> selectGiftByProductCodes(@Param("productCodes") String[] productCodes,
                                                       @Param("pType") PromotionType pType);

    List<Map<String, Object>> selectGiftBySkuIds(@Param("skuIds") Long[] skuIds, @Param("pType") PromotionType pType);

    List<YgSkuToProductModel> selectBySkuCodes(@Param("skuCodes") String[] skuCodes,
                                               @Param("pType") PromotionType pType);

    List<YgSimilarProductModel> findSimilarityProductWidthEqualBrand(@Param("brandName") String brandName,
                                                                     @Param("categoryId") Long categoryId);

    List<YgSimilarProductModel> findSimilarityProductWidthNoEqualBrand(@Param("brandName") String brandName,
                                                                       @Param("categoryId") Long categoryId);

    int updateBatchChechStatus(@Param("checkStatus") String checkStatus, @Param("ids") Long[] ids);

    List<YgProduct> selectByProductCodes(@Param("productCodes") String[] productCodes,
                                         @Param("pType") PromotionType pType);

    List<YgProduct> selectProductForPromotion(@Param("queryInfo") QueryInfo queryInfo,
                                              @Param("productName") String productName, @Param("groupId") Long groupId,
                                              @Param("productStatus") String productStatus,
                                              @Param("supplierId") Long supplierId,
                                              @Param("promotionId") Long promotionId,
                                              @Param("isSpecial") Boolean isSpecial);

    int updateSaleStatusByTask(@Param("ids") List<Long> ids);

    List<Long> selectProductNoStock();

    List<YgProduct4ShaidanModel> findProduct4ShaidanModel(@Param("queryInfo") QueryInfo queryInfo,
                                                          @Param("userId") Long userId);

    List<YgProduct4ShaidanModel> findProductAllModel(@Param("queryInfo") QueryInfo queryInfo);

    int findProductAllModelCount();

    int findProduct4ShaidanModelCount(@Param("userId") Long userId);

    List<YgProduct4ListModel> findList(@Param("queryInfo") QueryInfo queryInfo,
                                       @Param("saleStatus") ProductStatus saleStatus,
                                       @Param("productIds") String[] productIds,
                                       @Param("categoryIds") List<Long> categoryIds,
                                       @Param("isPreProduct") Boolean isPreProduct,
                                       @Param("gender") String gender, @Param("productName") String productName,
                                       @Param("tags") String tags, @Param("isVip") Boolean isVip,
                                       @Param("supplierId") Long supplierId);

    int findListCount(@Param("saleStatus") ProductStatus saleStatus, @Param("productIds") String[] productIds,
                      @Param("categoryIds") List<Long> categoryIds, @Param("isPreProduct") Boolean isPreProduct,
                      @Param("gender") String gender, @Param("productName") String productName,
                      @Param("tags") String tags, @Param("isVip") Boolean isVip, @Param("supplierId") Long supplierId);

    List<YgProduct> selectProductByPromotionId(@Param("queryInfo") QueryInfo queryInfo,
                                               @Param("promotionId") Long promotionId);

    List<YgProduct> selectProductInPack(@Param("productId") Long productId);

    int findHotProductCount(HotProductSaleQueryReq queryReq);

    List<YgHotProductModel> findHotProduct(HotProductSaleQueryReq queryReq);

    List<YgProductSaleNumAndCommentNumModel> findSaleNumAndCommentNum();

    void updateProductSaleNumAndCommentNum(@Param("list") List<YgProductSaleNumAndCommentNumModel> list);

    int updateSalesStatusByProductCode(@Param("updateBy") String updateBy, @Param("updateTime") Date updateTime,
                                       @Param("saleStatus") String saleStatus, @Param("productCode") String productCode,
                                       @Param("saleTime") Date saleTime);

    List<String> selectAllPreProductSkuCodes();

    List<YgProduct> selectProductList(@Param("productName") String q, @Param("productStatus") String productStatus,
                                      @Param("groupId") Long groupId, @Param("isSpecial") Boolean isSpecial,
                                      @Param("productCode") String productCode, @Param("isGroup") Boolean isGroup,
                                      @Param("promotionType") PromotionType promotionType,
                                      @Param("supplierId") Long supplierId);

    void updatePromotionPrice(@Param("promotionPrice") BigDecimal promotionPrice, @Param("groupId") Long groupId,
                              @Param("updateBy") String updateBy, @Param("updateTime") Date updateTime,
                              @Param("shareRate") BigDecimal shareRate, @Param("vipRate") BigDecimal vipRate,
                              @Param("distributionPrice") BigDecimal distributionPrice);

    String selectActionSkuIds();

    Map<String, Object> findProductBySkuId(@Param("skuCode") String skuCode, @Param("productId") Long productId);

    List<Map<String, Object>> findProductListBySupplierId(@Param("supplierId") Long supplierId);

    List<Map<String, Object>> findProductByGroupId(@Param("supplierId") Long supplierId,
                                                   @Param("groupId") Long groupId);

    List<YgSkuModel> selectSku(@Param("productId") Long productId);

    List<String> selectSkuCodeByProductIds(@Param("productIds") List<Long> productIds);

    YgProduct findProductById(@Param("pType") PromotionType pType, @Param("productId") Long productId);

    int updateRebate(@Param("shareRate") BigDecimal shareRate, @Param("supplierId") Long supplierId);

    List<YgProduct4ListModel> findProduct4ListModelByIds(@Param("queryInfo") QueryInfo queryInfo,
                                                         @Param("ids") List<Long> ids,
                                                         @Param("salesPlatform") SalesPlatform salesPlatform);

    List<YgProduct> selectBySkuCodesV2(@Param("pType") PromotionType pType, @Param("skuCodes") String... skuCodes);

    List<YgProduct> selectProductByTime(@Param("queryInfo") QueryInfo queryInfo, @Param("startTime") Date startTime,
                                        @Param("endTime") Date endTime,
                                        @Param("promotionType") PromotionType promotionType,
                                        @Param("productStatus") ProductStatus productStatus);

    List<YgProduct4ListModel> selectProductWithImageByIds(@Param("ids") List<Long> ids);

    int updateProductNameAndSalePrice(@Param("list") List<YgProduct> productList);

    int selectOrdinaryProductCount(@Param("name") String name, @Param("packId") Long packId);

    List<YgProduct4ListModel> selectOrdinaryProduct(@Param("name") String name, @Param("queryInfo") QueryInfo queryInfo,
                                                    @Param("packId") Long packId);

    List<Map<String, Object>> selectPidAndPcodeBySkuCodes(@Param("skuCodes") String... skuCodes);

    List<ProductInfoForSolr> selectProductListForSolr(@Param("productIds") List<Long> productIds);

    int updateCategoryAndBasicAttributeByProductCode(@Param("categoryId") Long categoryId,
                                                     @Param("basicAttribute") String basicAttribute,
                                                     @Param("categoryNames") String categoryNames,
                                                     @Param("list") List<String> productCodeList);

    int updateCategoryNamesByCategoryId(@Param("categoryId") Long categoryId);

    List<YgProduct4ListModel> selectByRequestParam(ProductListRequestParam param);

    YgProductModel findDetailModelForYjdian(@Param("productId") Long id);

    //后台商品列表页使用
    int countHoutaiProductList(@Param("productName") String productName, @Param("groupName") String groupName,
                               @Param("productStatus") String productStatus, @Param("supplierName") String supplierName,
                               @Param("isSpecial") Boolean isSpecial, @Param("productCode") String productCode,
                               @Param("isGroup") Boolean isGroup, @Param("preSaleDate") Boolean preSaleDate,
                               @Param("salesPlatform") SalesPlatform salesPlatform);

    List<Map<String, Object>> selectHoutaiProductList(@Param("queryInfo") QueryInfo queryInfo,
                                                      @Param("productName") String productName,
                                                      @Param("groupName") String groupName,
                                                      @Param("productStatus") String productStatus,
                                                      @Param("supplierName") String supplierName,
                                                      @Param("isSpecial") Boolean isSpecial,
                                                      @Param("productCode") String productCode,
                                                      @Param("isGroup") Boolean isGroup,
                                                      @Param("preSaleDate") Boolean preSaleDate,
                                                      @Param("salesPlatform") SalesPlatform salesPlatform);

    Long getSupplierIdByBarcode(@Param("barcode") String barcode);

    KidsProductExt selectProductInfoForKids(@Param("productId") Long productId);

    void updateBatchProductName(@Param("searchKey") String searchKey, @Param("distProductName") String distProductName,
                                @Param("trueName") String trueName, @Param("date") Date date);

    void updateProductNameByProductIds(@Param("productIds") String[] productIds,
                                       @Param("distProductName") String distProductName,
                                       @Param("trueName") String trueName, @Param("date") Date date);


    List<Map<String, Object>> selectProductListToExport(@Param("queryInfo") QueryInfo queryInfo,
                                                        @Param("productName") String productName,
                                                        @Param("groupName") String groupName,
                                                        @Param("productStatus") String productStatus,
                                                        @Param("supplierName") String supplierName,
                                                        @Param("isSpecial") Boolean isSpecial,
                                                        @Param("productCode") String productCode,
                                                        @Param("isGroup") Boolean isGroup,
                                                        @Param("preSaleDate") Boolean preSaleDate,
                                                        @Param("salesPlatform") SalesPlatform salesPlatform);


    int updatePromotionTag(@Param("promotionTag") String promotionTag, @Param("pidList") List<Long> pidList);

    List<ProductModelForGroup> selectProductByGroupOrder(@Param("queryInfo") QueryInfo queryInfo,
                                                         @Param("salesPlatform") String salesPlatform,
                                                         @Param("tags") String tags,
                                                         @Param("skipYg") boolean skipYg);

    List<YgProduct4ListModel> selectListGroupBySecondCategory(ProductListRequestParam param);

    List<YgProduct4ListModel> selectListGroupByProductGroup(ProductListRequestParam param);

    List<Product4SelectListModel> selectList4Select(ProductSelectListParam selectListParam);

    List<YgProduct> selectDetailBySaleTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime,
                                           @Param("salesPlatform") SalesPlatform salesPlatform);

    List<Long> selectPidListByBarcode(@Param("barcodeList") String[] barcodeList);

    List<KidsProductExt> selectProductDataByProductIds(@Param("pidList") List<Long> pidList);
}
